package cn.tedu.review;
/**
 * @Author 金帮嘉诚  @Date 2021-06-16 周三 20:59
 */
/*本类用于复习String中难点方法*/

import java.util.Arrays;

/**
 知识点：
 split()分割字符串，返回值是String数组，分割区分大小写
 */
public class ReviewStringAPI {
    public static void main(String[] args) {
        String s1="a b c d e";
        String[] sa1=s1.split(" ");
        for (int i = 0; i < sa1.length; i++) {
            System.out.println("sa1["+i+"] = " + sa1[i]);
        }
        //分割后空格消失，函数给其加了一个空格
        System.out.println("Arrays.toString(s1.split(\" \")) = " + Arrays.toString(s1.split(" ")));
        System.out.println("Arrays.toString(s1.split(\"b\")) = " + Arrays.toString(s1.split("b")));
        System.out.println("Arrays.toString(s1.split(\"c\")) = " + Arrays.toString(s1.split("c")));
        System.out.println("Arrays.toString(s1.split(\"%\")) = " + Arrays.toString(s1.split("%")));
        System.out.println("Arrays.toString(s1.split(\"B\")) = " + Arrays.toString(s1.split("B")));


    }
}
